package business.request;

import static common.Constant.CONTNO;
import static common.Constant.RATE;
import static common.Constant.TASK;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

import redis.clients.jedis.Jedis;

import common.util.JsonUtil;
import common.util.RedisPool;

public class AddTask {
    public static void main(String[] args) {
        Map<String, String> tMap = null;
        DecimalFormat df = new DecimalFormat("0.00");
        String tJson = null;
        Jedis tJedis = RedisPool.getJedis();
        for (int i = 0; i < 10000; i++) {
            tMap = new HashMap<String, String>();
            tMap.put(CONTNO, String.format("%013d", i));
            tMap.put(RATE, df.format(Math.random()));
            tJson = JsonUtil.getJson(tMap);
            tJedis.lpush(TASK, tJson);
            tJedis.publish(TASK, TASK);
        }
        tJedis.close();
    }

}
